package com.smasher.component.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.smasher.component.R
import com.smasher.component.holder.DecorationViewHolder
import com.smasher.decoration.group.GroupSwordDelegate
import com.smasher.widget.base.BaseRecyclerAdapter

class DecorationAdapter : BaseRecyclerAdapter<String, DecorationViewHolder>(), GroupSwordDelegate {
    /**
     * 创建ViewHolder
     *
     * @param viewGroup viewGroup
     * @param type      type
     * @return VH
     */
    override fun onCreateDefineViewHolder(viewGroup: ViewGroup, type: Int): DecorationViewHolder {
        val inflater = LayoutInflater.from(viewGroup.context)
        val view = inflater.inflate(R.layout.item_decoration_value, viewGroup, false)
        return DecorationViewHolder(view)
    }

    override fun getGroupName(position: Int): String {
        if (position < 10) {
            return "A"
        } else if (position < 20) {
            return "B"
        } else if (position < 30) {
            return "C"
        }
        return "Default"
    }

    override fun isGroupHeader(position: Int): Boolean {
        return position == 0 || position == 10 || position == 20
    }
}
